package com.shaco.heroproject.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.shaco.heroproject.R;
import com.shaco.heroproject.entity.Result_Video;

import java.util.List;

/**
 * Created by dllo on 15/11/4.
 */
public class HeroInforVideoAdapter extends RecyclerView.Adapter<HeroInforVideoAdapter.HeroInforVideoHolder> {
//    private RequestQueue queue;
    private List<Result_Video> result;
    public HeroInforVideoAdapter(Context c) {

//        queue = Volley.newRequestQueue(c);
    }

    @Override
    public HeroInforVideoHolder onCreateViewHolder(ViewGroup viewGroup, int position) {
        LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
        View v = inflater.inflate(R.layout.activity_hero_infor_video_item, null);
        return new HeroInforVideoHolder(v);
    }

    @Override
    public void onBindViewHolder(HeroInforVideoHolder holder, int position) {
        if (result != null && result.size() > 0) {
            Result_Video results = result.get(position);
            holder.hero_infor_video_titleTv.setText(results.getName());
            holder.hero_infor_video_timeTv.setText(results.getTtime());
//            if (results.getIcon() != null && results.getIcon().length() > 0) {
//                String imgUrl = results.getIcon();
//                getBitmap(imgUrl, holder.skill_allImg);
//            }
        }

    }

    @Override
    public int getItemCount() {
        return result != null && result.size() > 0 ? result.size() : 0;
    }

    class HeroInforVideoHolder extends RecyclerView.ViewHolder {
private TextView hero_infor_video_titleTv,hero_infor_video_timeTv;
        public HeroInforVideoHolder(View v) {
            super(v);
            // TODO Auto-generated constructor stub
            hero_infor_video_titleTv= (TextView) v.findViewById(R.id.hero_infor_video_titleTv);
            hero_infor_video_timeTv= (TextView) v.findViewById(R.id.hero_infor_video_timeTv);
        }

    }
    // 增加数据
    public void addData(List<Result_Video> results) {
        result = results;
        notifyDataSetChanged();
    }
}
